load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_library", "mongo_cc_unit_test")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

mongo_cc_library(
    name = "watchdog",
    srcs = [
        "watchdog.cpp",
    ],
    deps = [
        "//src/mongo/db:server_base",
        "//src/mongo/db:service_context",
        "//src/mongo/util/concurrency:spin_lock",
    ],
)

mongo_cc_library(
    name = "watchdog_register",
    srcs = [
        "watchdog_register.cpp",
    ],
    deps = [
        "//src/mongo:base",
    ],
)

idl_generator(
    name = "watchdog_mongod_gen",
    src = "watchdog_mongod.idl",
)

mongo_cc_library(
    name = "watchdog_mongod",
    srcs = [
        "watchdog_mongod.cpp",
        "watchdog_mongod_gen",
    ],
    deps = [
        ":watchdog",
        ":watchdog_register",
        "//src/mongo/db:server_base",
        "//src/mongo/db:service_context",
        "//src/mongo/db/commands/server_status:server_status_core",
        "//src/mongo/db/storage:storage_options",
    ],
)

mongo_cc_library(
    name = "watchdog_mock",
    srcs = [
        "watchdog_mock.cpp",
    ],
    deps = [
        ":watchdog",
        "//src/mongo/db:service_context",
    ],
)

mongo_cc_unit_test(
    name = "watchdog_test",
    srcs = [
        "watchdog_test.cpp",
    ],
    tags = ["mongo_unittest_eighth_group"],
    deps = [
        "watchdog",
        "//src/mongo/db:service_context_test_fixture",
        "//src/mongo/db/auth:authmocks",
        "//src/mongo/db/shard_role:service_context_non_d",
        "//src/mongo/util:clock_source_mock",
    ],
)
